<!DOCTYPE HTML>
<html>
	<head>
		<title>SOAP-Test for synchronous requests</title>
		<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
		<meta name="script" http-equiv="Content-Script-Type" content="text/javascript" />
		<meta name="script" http-equiv="Content-Style-Type" content="text/css" />
		<meta http-equiv="Access-Control-Allow-Origin" content="*">
		<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
		<script src="../persistence/database.js" type="text/javascript"></script>
                <script src="../business/business_objects/match.js" type="text/javascript"></script>
                <script src="../business/business_objects/group.js" type="text/javascript"></script>
                <script src="../business/business_objects/goal.js" type="text/javascript"></script>
		<script>
			function initDB() {
			    var database = new Database(function(){
                                var match = new Match();
                                match.setId(1);
                                match.setTeam1('TEST');
                                match.setTeam2('Deutschland');
                                match.setGroupId(1);
                                
                                var goal = new Goal();
                                goal.setId(1);
                                goal.setGoalComment("Test");
                                goal.setGoalGetterName("Florian Dulzky");
                                goal.setGoalMatchMinute("25");
                                goal.setGoalPenalty(false);
                                goal.setGoalScoreTeam1("1");
                                goal.setGoalScoreTeam2("0");
                                match.addGoal(goal);
                                
                                var goal2 = new Goal();
                                goal2.setId(2);
                                goal2.setGoalComment("Test");
                                goal2.setGoalGetterName("Florian Dulzky");
                                goal2.setGoalMatchMinute("35");
                                goal2.setGoalPenalty(true);
                                goal2.setGoalScoreTeam1("2");
                                goal2.setGoalScoreTeam2("0");
                                match.addGoal(goal2);
                                
                                database.setMatch(match);
                                database.getMatchById(1, function(data){
                                    console.log(data.getGoals());
                                });
                                
                                groupA = new Group();
                                groupA.setGroupId(1);
                                groupA.setGroupName("Gruppe A");
                                
                                groupB = new Group();
                                groupB.setGroupId(2);
                                groupB.setGroupName("Gruppe B");
                                
                                database.setGroup(groupA);
                                database.setGroup(groupB);
                                
                                database.getAllGroups(function(arrGroups){
                                    for(var key in arrGroups){
                                        console.log(arrGroups[key]);
                                    }
                                });
                                
                                database.getMatchesByGroupId(1, function(arrMatches){
                                    console.log(arrMatches);
                                });
                                
                                database.getGroupById(1, function(group){
                                   console.log(group);
                                });
                            });
			}
                        
		</script>
	</head>
	<body>
		<button onclick="initDB()">initDB</button>
	</body>
</html>